export default function throttle<T> (this: any, fun: (...args: any[])=>T, timeout = 200): (...args: any[])=>void {
    let timeoutId = -1;
    return (...args: any[]) => {
        if(timeoutId != -1) return;
        timeoutId = setTimeout(()=>{
            try {
                fun.apply(this, args);
            }finally {
                timeoutId = -1;
            }
        }, timeout);
    }
}
